﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PancakeSorting.Model;
using PancakeSorting.Utils;

namespace PancakeSorting
{
    public partial class PancakeForm : Form
    {
        private PancakeSort sorter;

        public PancakeForm()
        {
            InitializeComponent();

            sorter = new PancakeSort();
        }

        private void buttonSort_Click(object sender, EventArgs e)
        {
            string stringList = textBoxInput.Text;
            sorter = new PancakeSort(stringList);
            sorter.Sort();
            textBoxOutput.Text = sorter.SortedListToString;
            textBoxLog.Text = sorter.Log;
        }

        private void buttonClear_Click(object sender, EventArgs e)
        {
            textBoxInput.Text = "";
            textBoxOutput.Text = "";
            textBoxLog.Text = "";
        }

        private void buttonExport_Click(object sender, EventArgs e)
        {
            string path = IOUtils.SaveFileDialogShow(this, "Text Files|*.txt");
            IOUtils.CreateTxtFile(path, textBoxLog.Text);
            MessageBox.Show("Log Exported Succesfully");
        }
    }
}
